## 
set path /projects/cascade/workspace/xwqiu/RDL/innovus.20251106

source ${path}/RDL_Routing/proc_RDL.tcl
source ${path}/RDL_Routing/conf_RDL.tcl


proc pr_place_Metal {start end alist orientation layer width} {
	if { $orientation == "H"} {
		foreach i $alist {
			set pt_start "$start $i"
			set pt_end "$end $i"
			set pt {}
			lappend pt $pt_start $pt_end
			puts $pt
			pr_auto_edit_wire $layer VSS $width $pt
		}
	} elseif { $orientation == "V" } {
		foreach i $alist {
			set pt_start "$i $start"
			set pt_end "$i $end"
			set pt {}
			lappend pt $pt_start $pt_end
			puts $pt
			pr_auto_edit_wire $layer VDD $width $pt
		}
	} else {
		puts "place M11 ERROR!!"
	}
}

#### ---- run -------

proc pr_place_M13 { name } {

    global PAD
    global Metal
    global path

    if { $name == "NDPHY_bottom" } {
        set place_box {461.3 -9.354 8089.6975 839.578}
        set ori V
        set PAD_list $PAD(NDPHY,bottom_x)
    }

    if { $name == "NDPHY_left" } {
        set place_box {-15.695 851.557 837.366 7152.749}
        set ori H
        set PAD_list $PAD(NDPHY,left_y)
    }

    if { $name == "NDPHY_right" } {
        set place_box {7637.9465 883.696 8451.295 7089.7215}
        set ori H
        set PAD_list $PAD(NDPHY,right_y)
    }

    if { $name == "DDRPHY_left" } {
        set place_box {-3.289 7641.6215 707.042 10345.0385}
        set ori H
        set PAD_list $PAD(DDRPHY,left_y)
    }

    if { $name == "DDRPHY_right" } {
        set place_box {7710.914 7524.0015 8488.274 10410.8345}
        set ori H
        set PAD_list $PAD(DDRPHY,right_y)
    }

    if { $name == "DDRPHY_top1" } {
        set place_box {743.9495 9806.089 2082.5485 10575.6105}
        set ori V
        set PAD_list $PAD(DDRPHY,top_x1)
    }

    if { $name == "DDRPHY_top2" } {
        set place_box {6379.5685 9806.0895 7698.0195 10600.0055}
        set ori V
        set PAD_list $PAD(DDRPHY,top_x2)
    }




    if { $ori == "H" } {
        lappend PAD_list [lindex $place_box 1] [lindex $place_box 3]
        set list_from_py [exec /apps/mentor/aoi_cal_2018.4_17.10/bin/python3 ${path}/RDL_Routing/place_M11_PHY.py $PAD_list $Metal(M13_10p8,width) $Metal(M13_10p8,space)]
        set alist [lindex [pr_python_to_tcl $list_from_py] 0]
        pr_place_Metal [lindex $place_box 0] [lindex $place_box 2] $alist $ori M13 $Metal(M13_10p8,width)
    } elseif { $ori == "V" } {
        lappend PAD_list [lindex $place_box 0] [lindex $place_box 2]
        set list_from_py [exec /apps/mentor/aoi_cal_2018.4_17.10/bin/python3 ${path}/RDL_Routing/place_M11_PHY.py $PAD_list $Metal(M13_10p8,width) $Metal(M13_10p8,space)]
        set alist [lindex [pr_python_to_tcl $list_from_py] 0]
        pr_place_Metal [lindex $place_box 1] [lindex $place_box 3] $alist $ori M13 $Metal(M13_10p8,width)
    }

}